﻿using KayakMes.Common.Dtos.TeamDTO.Input;
using KayakMes.Common.Dtos.TeamDTO.Output;
using KayakMes.Common.Result;
using KayakMes.ProcessManagement.Application.Scheduling;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace KayakMes.ProcessManagement.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class SchedulingController : ControllerBase
    {
        private readonly ITeamTypeService _teamTypeService;
        private readonly ITeamSetService _teamSetService;
        private readonly IEmployeeService _employeeService;

        public SchedulingController(ITeamTypeService teamTypeService, ITeamSetService teamSetService, IEmployeeService employeeService)
        {
            _teamTypeService = teamTypeService;
            _teamSetService = teamSetService;
            _employeeService = employeeService;
        }

        /////-------------------------  班组类型  -------------------------




        /// <summary>
        /// 新增班组类型
        /// </summary>
        /// <param name="input">班组类型输入信息</param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> Add(TeamTypeInput input)
        {
            return _teamTypeService.Add(input);
        }

        /// <summary>
        /// 获取班组类型列表（分页）
        /// </summary>
        /// <param name="input">查询条件</param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<TeamTypeOutput> GetTeamTypeList([FromQuery]GetTeamTypeInput input)
        {
            return _teamTypeService.GetTeamTypeList(input);
        }

        /// <summary>
        /// 根据Id获取班组类型信息
        /// </summary>
        /// <param name="id">班组类型ID</param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<TeamTypeOutput> FindTeamType([FromQuery]long id)
        {
            return _teamTypeService.FindTeamType(id);
        }

        /// <summary>
        /// 根据Id删除班组类型
        /// </summary>
        /// <param name="id">班组类型ID</param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> DeleteTeamType(long id)
        {
            return _teamTypeService.DeleteTeamType(id);
        }

        /// <summary>
        /// 修改班组类型信息
        /// </summary>
        /// <param name="input">班组类型更新信息</param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateTeamType(TeamTypeOutput input)
        {
            return _teamTypeService.UpdateTeamType(input);
        }


        /////-------------------------  班组设置  -------------------------


        /// <summary>
        /// 添加班组设置
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddTeamSet(TeamSetInput input)
        {
            return _teamSetService.Add(input);
        }
        /// <summary>
        /// 删除班组设置
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> DeleteTeamSet(long id)
        {
            return _teamSetService.DeleteTeamSet(id);
        }
        /// <summary>
        /// 根据ID查询班组设置
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<TeamSetOutput> FindTeamSet([FromQuery]long id)
        {
            return _teamSetService.FindTeamSet(id);
        }
        /// <summary>
        /// 查询班组设置列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<TeamSetOutput> GetTeamSetList([FromQuery]GetTeamSetInput input)
        {
            return _teamSetService.GetTeamSetList(input);
        }
        /// <summary>
        /// 修改班组设置
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> UpdateTeamSet(UpdateTeamSetInput input)
        {
            return _teamSetService.UpdateTeamSet(input);
        }


        /////-------------------------  班组成员设置  -------------------------

        /// <summary>
        /// 添加员工信息
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> AddEmployee(EmployeeInput input)
        {
            return _employeeService.Add(input);
        }

        /// <summary>
        /// 删除员工信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> DeleteEmployee(long id)
        {
            return _employeeService.DeleteEmployee(id);
        }

        /// <summary>
        /// 根据ID查询员工信息
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiResult<EmployeeOutput> FindEmployee([FromQuery]long id)
        {
            return _employeeService.FindEmployee(id);
        }

        /// <summary>
        /// 查询员工列表
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<EmployeeOutput> GetEmployeeList([FromQuery]GetEmployeeInput input)
        {
            return _employeeService.GetEmployeeList(input);
        }

        /// <summary>
        /// 根据班组ID查询员工列表
        /// </summary>
        /// <param name="teamSetId"></param>
        /// <returns></returns>
        [HttpGet]
        public ApiPaging<EmployeeOutput> GetEmployeesByTeamSetId([FromQuery]long teamSetId)
        {
            return _employeeService.GetEmployeesByTeamSetId(teamSetId);
        }

        /// <summary>
        /// 批量修改员工班组
        /// </summary>
        /// <param name="employeeIds"></param>
        /// <param name="teamSetId"></param>
        /// <returns></returns>
        [HttpPost]
        public ApiResult<int> BatchUpdateEmployeeTeamSet(List<long> employeeIds, long teamSetId)
        {
            return _employeeService.BatchUpdateEmployeeTeamSet(employeeIds, teamSetId);
        }
    }
}
